﻿/*
 * Erstellt mit SharpDevelop.
 * Benutzer: mime
 * Datum: 28.07.2009
 * Zeit: 19:47
 * 
 * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
 */
using System;
using System.Collections.Generic;

namespace Stone
{
    ///// <summary>
    ///// Description of Transformer.
    ///// </summary>
    //public class Transformer
    //{
    //    private List<RoutingPoint> points;
    //    private int start;
    //    private int end;
    //    private int x1;
    //    private int y1;
    //    private int x2;
    //    private int y2;
    //    private double longitude1;
    //    private double latitude1;
    //    private double longitude2;
    //    private double latitude2;
		
    //    public Transformer(ref List<RoutingPoint> points, int start, int end, int x1, int y1, int x2, int y2, double longitude1, double latitude1, double longitude2, double latitude2)
    //    {
    //        this.points = points;
    //        this.start = start;
    //        this.end = end;
    //        this.x1 = x1;
    //        this.y1 = y1;
    //        this.x2 = x2;
    //        this.y2 = y2;
    //        this.longitude1 = longitude1;
    //        this.latitude1 = latitude1;
    //        this.longitude2 = longitude2;
    //        this.latitude2 = latitude2;
    //    }
		
    //    public void startTransforming() {
    //        for(int i=start; i<end; i++) {
    //            int xp = 0;
    //            int yp = 0;
				
    //            RoutingPoint rp = points[i];
    //            this.transform(x1,y1,x2,y2,longitude1,latitude1,longitude2,latitude2,rp.LONGITUDE,rp.LATITUDE,ref xp, ref yp);
    //            rp.X = xp;
    //            rp.Y = yp;
    //        }
    //    }
		
    //    /// <summary>
    //    /// berechnet die Koordinaten fuer einen Punkt auf dem Bildschirm
    //    /// </summary>
    //    /// <param name="x1">pixel oben links</param>
    //    /// <param name="y1">pixel oben links</param>
    //    /// <param name="x2">pixel unten rechts</param>
    //    /// <param name="y2">pixel unten rechts</param>
    //    /// <param name="longitude1">longitude oben link</param>
    //    /// <param name="latitude1">latitude oben links</param>
    //    /// <param name="longitude2">longitude unten rechts</param>
    //    /// <param name="latitude2">latitude unten rechts</param>
    //    /// <param name="longitudep">longitude des zu malenden punkts</param>
    //    /// <param name="latitudep">latitude des zu malenden punkts</param>
    //    /// <param name="xp">x koordinate des zu malenden punkts</param>
    //    /// <param name="yp">y koordinate des zu malenden punkts</param>
    //    protected void transform(int x1, int y1, int x2, int y2, double longitude1, double latitude1, double longitude2, double latitude2, double longitudep, double latitudep, ref int xp, ref int yp) {
        
    //        int xspan = x2 - x1;
    //        int yspan = y2 - y1;
        	
    //        double lonfaktor = (longitudep - longitude1) / (longitude2 - longitude1);
    //        double latfaktor = (latitude1 - latitudep) / (latitude1 - latitude2);
        	
    //        xp = (int) (xspan * lonfaktor);
    //        yp = (int) (yspan * latfaktor);

    //        xp -= 256;
    //        yp -= 256;
        	
    //    }
    //}

    //public class PixelTransformer {

    //    /// <summary>
    //    ///  soll Lat und Lon berechnen, nach einen Klick auf die Karte
    //    /// </summary>
    //    public static void pixelToLatLon(double lat1, double lon1, double lat2, double lon2, int px1, int py1, int px2, int py2, ref double latp, ref double lonp, int xclick, int yclick) {
    //        double lonspan = lon2 - lon1;
    //        double latspan = lat1 - lat2;

    //        int xspan = px2 - px1;
    //        int yspan = py2 - py1;

    //        double zxp1 = xclick - px1;
    //        double restx = zxp1 / xspan;
    //        double addx = restx * lonspan;
    //        lonp = lon1 + addx;

    //        /////
    //        double zyp1 = yclick - py1;
    //        double resty = zyp1 / yspan;
    //        double addy = resty * latspan;
    //        latp = lat1 - addy;
            

    //    }

    //}

    //public class Compass {

    //    public static readonly int E = 1;
    //    public static readonly int NE = 2;
    //    public static readonly int N = 3;
    //    public static readonly int NW = 4;
    //    public static readonly int W = 5;
    //    public static readonly int SW = 6;
    //    public static readonly int S = 7;
    //    public static readonly int SE = 8;

    //    public static int getCompass(double a) {

    //        int compass = -1;

    //        if ((a <= 22.5 && a >= 0) || (a >= 337.5)) {
    //            compass = E;
    //        } else if (a > 22.5 && a <= 67.5) {
    //            compass = NE;
    //        } else if (a > 67.5 && a <= 112.5) {
    //            compass = N;
    //        } else if (a > 112.5 && a <= 157.5) {
    //            compass = NW;
    //        } else if (a > 157.5 && a <= 202.5) {
    //            compass = W;
    //        } else if (a > 202.5 && a <= 247.5) {
    //            compass = SW;
    //        } else if (a > 247.5 && a <= 292.5) {
    //            compass = S;
    //        } else if (a > 292.5 && a < 337.5) {
    //            compass = SE;
    //        }


    //        return compass;

    //    }

    //    public static int getCompass(double x, double y) {
    //        return getCompass(Trigonometry.calcWholeAngel(x, y));
    //    }

    //}


    //public class Trigonometry {

    //    public static readonly int QU_1 = 1;
    //    public static readonly int QU_2 = 2;
    //    public static readonly int QU_3 = 3;
    //    public static readonly int QU_4 = 4;


    //    public static double calcWholeAngel(double x, double y) {
    //        double winkel = calcAngelForTriangle(x, y);
    //        int quadrant = getQuadrant(x, y);

    //        if (quadrant == QU_2) {
    //            winkel = 90.0 + (90.0 - winkel);
    //        } else if (quadrant == QU_3) {
    //            winkel = 180.0 - winkel;
    //        } else if (quadrant == QU_4) {
    //            winkel = 270.0 - winkel;
    //        }

    //        return winkel;
    //    }


    //    public static int getQuadrant(double x, double y) {
    //        int quadrant = -1;

    //        if (x >= 0 && y >= 0) {
    //            quadrant = QU_1;
    //        } else if (x <= 0 && y >= 0) {
    //            quadrant = QU_2;
    //        } else if (x <= 0 && y <= 0) {
    //            quadrant = QU_3;
    //        } else if (x >= 0 && y <= 0) {
    //            quadrant = QU_4;
    //        }

    //        return quadrant;
    //    }



    //    public static double calcAngelForTriangle(double x1, double y1) {
    //        double b = Math.Pow(x1, 2) + Math.Pow(y1, 2);
    //        b = Math.Sqrt(b);
    //        double sin_a = y1 / b;
    //        double alpha = Math.Asin(sin_a);
    //        double winkel = (180 / Math.PI) * alpha;

    //        return winkel;
    //    }

    //}


}
